package com.fancy.learncenter.ui.activity;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.activity.base.BaseActivity;
import com.fancy.learncenter.ui.adapter.ViewPageAdapter;
import com.fancy.learncenter.ui.callback.AlbumImpl;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class LargeImageActivity extends BaseActivity {

    @Bind(R.id.view_pager)
    ViewPager viewPager;
    @Bind(R.id.show_position)
    TextView showPosition;

    private ArrayList<String> list = new ArrayList<>();
    private int position = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_large_image, Status.NAVIGATION);
        ButterKnife.bind(this);
        getIntentData();
        initData();
    }

    private void getIntentData(){
        list = getIntent().getStringArrayListExtra("list");
        position = getIntent().getIntExtra("position",0);
    }

    private void initData() {

        viewPager.setAdapter(new ViewPageAdapter(this, list, new AlbumImpl() {
            @Override
            public void onClick(int position) {

                finish();
            }
        }));
        viewPager.setCurrentItem(position);
        showPosition.setText(position+1 +"/" + list.size());
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

                showPosition.setText(position + 1 +"/" + list.size());

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }


}
